package com.dao.impl;

import com.dao.TableDao;
import com.models.Column;
import com.util.Constants;
import com.models.Table;
import org.junit.Test;

/**
 * Created by timeliar on 15-9-29.
 *
 */
public class TableDaoImplTest {
    private TableDao tableDao;
    private Table table;
    public TableDaoImplTest(){
        tableDao = new TableDaoImpl();
        table = new Table();
        table.setName("tableA");
        table.getColumns().add(new Column("id",Constants.INT,11,true,true));
        table.getColumns().add(new Column("name",Constants.VARCHAR,45));
        table.getColumns().add(new Column("sex",Constants.BOOLEAN,1));
    }
    @Test
    public void testAdd() throws Exception {
        tableDao.add(table);
    }

    @Test
    public void testDelete() throws Exception {
        tableDao.delete("tableA");
    }

    @Test
    public void testUpdate() throws Exception {
        table.getColumns().remove(1);
        tableDao.update(table);
    }

    @Test
    public void testGetTable() throws Exception {
        System.out.println(tableDao.getTable("tableA"));
    }
}